<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	 <link type="text/css" href="../css/jquery-ui-1.8.17.custom.css" rel="stylesheet" />
    <link type="text/css" href="../css/jquery-ui-timepicker-addon.css" rel="stylesheet" />
 	<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-1.8.17.custom.min.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-timepicker-addon.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-timepicker-zh-CN.js"></script>
<title>考试系统</title>
<style type="text/css">
<!--
body {
	margin-left: 3px;
	margin-top: 0px;
	margin-right: 3px;
	margin-bottom: 0px;
}
.STYLE1 {
	color: #e1e2e3;
	font-size: 12px;
}
.STYLE6 {color: #000000; font-size: 12; }
.STYLE10 {color: #000000; font-size: 12px; }
.STYLE19 {
	color: #344b50;
	font-size: 12px;
}
.STYLE21 {
	font-size: 12px;
	color: #3b6375;
}
.STYLE22 {
	font-size: 12px;
	color: #295568;
}
-->
</style>
<script type="text/javascript">
        $(function () {
            $(".ui_timepicker").datetimepicker({
                //showOn: "button",
                //buttonImage: "./css/images/icon_calendar.gif",
                //buttonImageOnly: true,
                changeMonth: true,  
                changeYear: true ,
                showSecond: true,
                timeFormat: 'hh:mm:ss',
                stepHour: 1,
                stepMinute: 1,
                stepSecond: 1
            })
        })
        var flag = true;
        function check(){
        	flag = true;
        	$("#info").text("");
        	var name = $.trim($("#name").val());
        	var begintime = $("#btime").val();
        	var endtime = $("#etime").val();
        	if(name.length == 0 || begintime.length == 0 || endtime.length ==0){
        		flag = false;
        		$("#info").text("请将信息填写完整");
        		return  ;
        	}
        	
        	begintime = new Date(begintime.replace(/-/ig,'/'));
        	endtime = new Date(endtime.replace(/-/ig,'/'));
        	
        	if(endtime <= begintime){
        		alert("time errror");
        		$("#info").text("请填写正确时间");
        		flag=false;
        		return  ;
        	}
        	
        }
        
        
        function go(){
        	 check();
        	if(flag){
        		$("#addexam").submit();
        	}
        	else{
        		$("#info").text("信息填写有误");
        	}
        	
        	
        }
        
        function addclazz(){
        	check();
        	if(flag){
        	form1.action="<%= request.getContextPath() %>/Clazz/ClazzAction!addpaperclazz.action";
        	form1.submit();	
        	}
        	else{
        		$("#info").text("信息填写有误");
        	}
        }
    </script>
</head>

<body>

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1"> 添加考试</span></td>
              </tr>
            </table>
            </td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
  <td>
    <form name="form1" id="addexam" action="<%=path %>/Teacher/TeacherAction!Paperadd.action" method="post">
	<table width="30%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
		<tr>
			 <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">考试编号 </span></div></td>
			 <td height="20" bgcolor="d3eaef" class="STYLE19"><div align="center">${paper.id } <input type="hidden" name="paper.id" value='<s:property value="paper.id"/>' readonly /> </div></td>
		</tr>
		<tr>
			 <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">考试名称</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left"> <input type="text" name="paper.papername" id="name" size="35" /> </div></td>
		</tr>
		<tr>
			 <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">开始时间</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left" > 			
			 <input type="text" name="paper.begintime" id="btime"  class="ui_timepicker" value="">
			 </div></td>
		</tr>
		<tr>
			 <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">结束时间</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left"> 
			<input type="text" name="paper.endtime" id="etime"  class="ui_timepicker" value="">
			 </div></td>
		</tr>
		<tr>
			 <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">类型</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left"> 
			 <select name="paper.isjava">
			 	<option value="0" >JAVA</option>
			 	<option value="1" selected>C++</option>
			 </select> </div></td>
		</tr>
		<tr>
			 <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">考试密码</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left"> <input type="text" name="paper.paperpw" /> </div></td>
		</tr>
		<tr>
			 <td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">是否安排排名</span></div></td>
			 <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="left"> 
             <select name="paper.rank">
                <option value="1" >是</option>
                <option value="0" selected>否</option>
             </select> </div></td>
		</tr>
		<tr>
			<td width="30%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10"> <input type="button" value="提交" onclick ="go()"/></span></div></td>
			<td height="20"  class="STYLE19"><div align="center"><input type="button" value="添加班级" onclick="addclazz()" /> </div></td>
		</tr>
		
		<tr><td colspan="2" > <div id ="info" style="color: red; background-color: white;text-align: center" ></div> </td></tr>
		
	</table>
	</form>
  </td>
  </tr>
</table>	
    		
</body>
</html>
